<include file="header2"/>
<div class="wraper">
    <header class="text-center font-white font-16">
        <div class="back iconfont icon-back"></div>
        审核不通过
    </header>
    <div class="box margin-t12">
        <div class="list">
            <textarea name="" id="reason" cols="30" rows="4" placeholder="请输入不通过理由" class="font-gray2"></textarea>
            <p class="text-right font-blue font-12 number">0/300</p>
        </div>

    </div>
    <a type="button" id="noAdd" class="submit text-center font-16">提交</a>
</div>
<script src="/assets/base/officialcar/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/officialcar/js/layer.js"></script>
<script src="/assets/base/officialcar/js/public.js"></script>
<script>
    $(function () {
        var num = 0;
        var maxlength = 300;
        $('textarea').bind('input', function () {
            var strlen = $(this).val().replace(/[^\x00-\xff]/g, "aa").length;  //中文算两个字符 英文算一个字符
            $('textarea').text(function () {
                //Math.ceil(x) 对一个数进行上舍入 返回值 大于等于 x，并且与它最接近的整数。
                if (Math.ceil(strlen / 2) <= maxlength) {
                    num = Math.ceil(strlen / 2) + '/300';
                    $('.number').html(num);
                } else {
                    fm.alert('字数超出限制');
                    $(this).val($(this).val().substr(0, $(this).val().length - 1));
                }
            });
        });
    })
    $(document).on('click','#noAdd',function(){
        var reason = $('#reason').val();
        var conf_id = {BEESCRM:$conf_id};
        var order_id = {BEESCRM:$order_id};
        if(!reason){
            fm.alert('请填写理由');
            return false;
        }

        $.ajax({
            url:"/base/OfficialCar/noReason/conf_id/"+conf_id,
            data:{reason:reason,order_id:order_id},
            type:'post',
            dataType:'json',
            success:function(res){
                if(res.status=='S'){
                    fm.alert(res.message);
                    setTimeout(reload(),2000);
                }else{
                    fm.alert(res.message);
                }
            }
        });
    });
    function reload(){
        var conf_id = {BEESCRM:$conf_id};
        window.location.href="/base/OfficialCar/dispatcher/conf_id/"+conf_id;
    }
</script>
<include file="footer"/>